<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Home_model extends CI_Model {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */



	public function queryListData($sortByField='publish_date',$pageItemCount=20)
	{


		$this->load->database();

		//使用CI内置数据库查询方法，简化查询语句
		$this->db->select('`slide_id`,`title`,`thumbnail`,`slide_item_tb.summary`,`creator_id`,`view_count`,`publish_date`,`user_item_tb.username`');
		$this->db->join('user_item_tb','slide_item_tb.creator_id=user_item_tb.uid','left');
		
		$data=$this->db->order_by($sortByField,'DESC')->get_where('slide_item_tb',array('audit_status'=>1),$pageItemCount,0)->result_array();


		if(empty($data)){
			return NULL;
			exit;
		}

		return $data;

	}




}
